how to add an element at the end of an array dinamicaly